﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

using BrightIdeasSoftware;

namespace FCNS.KeepMoney.Util
{
    public enum HotItemStyleEnum
    {
        None,
        TextColor,
        Border,
        Translucent,
        Lightbox
        //Vista
    }

    public class HotItemStyleUtil
    {
        public static void SetHotItemStyle(ObjectListView olv, bool businessCardOverlay)
        {
            olv.UseTranslucentHotItem = false;
            olv.UseHotItem = true;
            olv.FullRowSelect = true;
            olv.UseExplorerTheme = false;

            HotItemStyle hotItemStyle = new HotItemStyle();
            switch (Program.AppConfig.MainForm.HotItemStyle)
            {
                case HotItemStyleEnum.None:
                    olv.UseHotItem = false;
                    break;

                case HotItemStyleEnum.TextColor:
                    hotItemStyle.ForeColor = Color.AliceBlue;
                    hotItemStyle.BackColor = Color.FromArgb(255, 64, 64, 64);
                    olv.HotItemStyle = hotItemStyle;
                    break;

                case HotItemStyleEnum.Border:
                    RowBorderDecoration rbd = new RowBorderDecoration();
                    rbd.BorderPen = new Pen(Color.SeaGreen, 2);
                    rbd.FillBrush = null;
                    rbd.CornerRounding = 4.0f;
                    hotItemStyle.Decoration = rbd;
                    olv.HotItemStyle = hotItemStyle;
                    break;

                case HotItemStyleEnum.Translucent:
                    olv.UseTranslucentHotItem = true;
                    break;

                case HotItemStyleEnum.Lightbox:
                    hotItemStyle.Decoration = new LightBoxDecoration();
                    olv.HotItemStyle = hotItemStyle;
                    break;

                //case HotItemStyleEnum.Vista:
                //    olv.FullRowSelect = true;
                //    olv.UseHotItem = false;
                //    olv.UseExplorerTheme = true;

                //    // Using Explorer theme doesn't work in owner drawn mode
                //    if (olv == this.olvFiles)
                //        this.checkBox10.Checked = false;
                //    if (olv == this.olvComplex)
                //        this.checkBox6.Checked = false;
                //    break;
            }

            // Make the hot item show an overlay when it changes
            if (businessCardOverlay)
            {
                olv.HotItemStyle.Overlay = new UI.BusinessCardOverlay();
                olv.HotItemStyle = olv.HotItemStyle;
            }

            olv.UseTranslucentSelection = olv.UseTranslucentHotItem;

            olv.Invalidate();
        }
    }
}
